package com.naire.modul.employee.action;

import java.util.ArrayList;
import java.util.List;

import net.common.action.GeneralAction;

import com.naire.modul.employee.service.EmployeeDeleteService;
import com.naire.modul.employee.service.EmployeeEditorService;
import com.naire.modul.employee.service.EmployeeFindService;
import com.naire.modul.employee.service.EmployeeSearchService;
import com.naire.modul.employee.service.EmployeeSelectService;
import com.naire.modul.employee.vo.EmployeeVo;

public class EmployeeAction extends GeneralAction {

	private static final long serialVersionUID = 7127573666355745443L;

	private EmployeeVo bean = new EmployeeVo();
	private List<EmployeeVo> list = new ArrayList<EmployeeVo>();
	private Integer dept_id;
	private String dept_num;
	@SuppressWarnings("rawtypes")
	private List objList;

	public void searchEmployeeTree() throws Exception {
		EmployeeSelectService service = new EmployeeSelectService();
		service.setDept_num(dept_num);
		service.setDept_id(dept_id);
		service.invoke();
		json(service.getList());
	}

	public String search() throws Exception {
		EmployeeSearchService service = new EmployeeSearchService();
		service.setPageBean(pageBean);
		service.setDept_id(dept_id);
		service.invoke();
		list = service.getList();
		return SUCCESS;
	}

	public String editor() throws Exception {
		EmployeeEditorService service = new EmployeeEditorService();
		service.setBean(bean);
		service.setDept_id(dept_id);
		service.invoke();
		return SUCCESS;
	}

	public String find() throws Exception {
		if (bean.getEmpl_id() != null) {
			EmployeeFindService service = new EmployeeFindService();
			service.setId(bean.getEmpl_id());
			service.invoke();
			bean = service.getBean();
		}
		return SUCCESS;
	}

	public String delete() throws Exception {
		EmployeeDeleteService service = new EmployeeDeleteService();
		service.setBean(bean);
		service.invoke();
		return SUCCESS;
	}

	public EmployeeVo getBean() {
		return bean;
	}

	public void setBean(EmployeeVo bean) {
		this.bean = bean;
	}

	public List<EmployeeVo> getList() {
		return list;
	}

	public void setList(List<EmployeeVo> list) {
		this.list = list;
	}

	public void setDept_id(Integer dept_id) {
		this.dept_id = dept_id;
	}

	public Integer getDept_id() {
		return dept_id;
	}

	public String getDept_num() {
		return dept_num;
	}

	public void setDept_num(String dept_num) {
		this.dept_num = dept_num;
	}

	@SuppressWarnings("rawtypes")
	public List getObjList() {
		return objList;
	}

	@SuppressWarnings("rawtypes")
	public void setObjList(List objList) {
		this.objList = objList;
	}

}
